package util;

import primatives.PointND;

/**
 * Edge used for clustering
 * @author Po
 *
 */

public class ClusterEdge implements Comparable
{
	public PointND start;
	public PointND end;
	public double length;
	public boolean bRender;
	
	public ClusterEdge()
	{
		start = end = null;
		length = 0.0;
		bRender = false;
	}
	
	public ClusterEdge(PointND s, PointND e)
	{
		start = s;
		end = e;
		length = s.get_distance(e, 3);
		bRender = true;
	}
	
	public boolean equals(Object o)
	{
		ClusterEdge other = (ClusterEdge) o;
		if (this.start.equals(other.start) && this.end.equals(other.end)) return true;
		if (this.start.equals(other.end) && this.end.equals(other.start)) return true;
		return false;
	}

	@Override
	public int compareTo(Object o)
	{
		ClusterEdge other = (ClusterEdge) o;
		if (this.length < other.length) return -1;
		else if (this.length == other.length) return 0;
		else return 1;
	}
}
